#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSqlTableModel>

#include "Database.h"

enum StudentSex { MALE, FEMALE, UNKNOWN };

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow {
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);

    ~MainWindow() override;

    static int exitCode;

private slots:

    void on_g_index_clicked();

    void on_g_search_clicked();

    void on_g_profile_clicked();

    void on_g_book_clicked();

    void on_g_person_clicked();

    void on_g_logout_clicked();

    void on_g_exit_clicked();

    void on_b_about_clicked();

    void on_b_return_clicked();

    void on_b_search_clicked();

    void on_b_person_clicked();

    void on_b_book_clicked();

    void on_b_profile_clicked();

    void on_b_filter_book_clicked();

    void on_b_rollback_book_clicked();

    void on_b_add_book_clicked();

    void on_b_delete_book_clicked();

    void on_b_check_admin_clicked();

    void on_b_check_student_clicked();

    void on_b_add_person_clicked();

    void on_b_delete_person_clicked();

    void on_b_filter_book2_clicked();

    void on_b_rollback_book2_clicked();

    void on_g_return_clicked();

    void on_b_borrow_clicked();

    void on_return_book_clicked();

    void on_reload_borrow_clicked();

    void on_update_clicked();

    void on_confirm_clicked();

    void on_cancel_clicked();

private:
    Ui::MainWindow *ui;

    Database *database;

    // 处理主窗口关闭的行为
    void closeEvent(QCloseEvent *event) override;

    bool isAdmin;

    // 用来记录用户的登录信息（以学生身份）
    int studentId;
    QString studentName;
    QString studentAccount;
    QString studentPassword;
    QString studentNumber;
    StudentSex studentSex;
    int studentBorrowBook;

    // 以管理员身份记录
    QString adminAccount;
    QString adminPassword;
};

#endif  // MAINWINDOW_H
